home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 10
/
Commodore_Free_Issue_10_2007_Commodore_Computer_Club.d64
/
t.slang ref
< prev
next >
Wrap
Text File
|
2023-02-26
|
2KB
|
145 lines
u Slang Quick Reference guide
Numbers and misc
; ;comment
* ;comment when in 1st column
a=1234 ;base 10
a=$1234 ;base 16
a=%11010 ;base
2
a=a + & ;line continuation
b
a$="Howdy" ;strings -- " or ' allowed
delimeters
a$=!5"hola"!13 ;like
chr$(5)+"hola"+chr$(13)
a$=!s"hey" ;!s -- use screen codes
instead of petscii
;!r v use regular (petscii) codes
;!n v negate (ora $80) following
codes
;!z v do not null-terminate string
Slang is CaSe InSeNsItIvE
Variable types and declarations
byte, ubyte ;1 byte, signed/unsigned
int, uint ;2 bytes, signed/unsigned
float ;5 bytes, MFLPT format
byte blah@$d020 ;@-var: locate
variable at $d020
int screen(25,40)@$0400 ;Create 2D
array, locate at text screen
int blah(3,3)=[ [1 2 3]
&
[4 5 6]
&
[7 8 9] ] ;Create 2D array and
pre-initialize values
ubyte str(50)=['..can also use strings
to pre-initialize'
]
blah(2,0) = 1 ;Note that array indices
start at
0
byte ^test ;Create 16-bit pointer to a
byte
byte ^^test2(20,10) ;24-bit pointer to
byte array
test=$c000 ;set point location: lda
#$c000 sta zp
^test=10 ;set location value: lda #10
sta (zp),
y
test2=$123456 ;set array base address
test2(3,5)=10 ;leading ^ not used with
arrays
deftype foo ;Compound variable type
declaration
int .a ;note leading
.
byte .b(10)
float .
x
defend
type foo yak1, yak2 ;Create two
variables of compound type foo
yak1.a = 10 ;...which can then access
individual elements
yak.b(3) = -
8
yak1.x = 3.1415926
VarBlock @$c000 ;Define following
variables starting at $c000
ubyte t1
int t2
EndVarBlock ;until the EndVarBlock
int b,
c
c=#b+3 ;Set c to the DaddressD of b
plus three
Strings
byte str(20) ;Strings are byte arrays,
null-terminated
str(1) = 1 ;Treat as byte array
str$="Hey!!"!13 ;Using the $ sign
treats as string
if str$(2:4) = "y!!" ;Can specify
substring ranges
str$(2)="blah" ;{SHIFT--}H{SHIFT--}e{SHIFT--}b{SHIFT--}l{SHIFT--}a{SHIFT--}h{SHIFT--}00
Subroutines
note: <- indicates backarrow key; use
D (underscore) on PC/xlang
sub blah() ;Subroutine with no input
or output variables
sub blah2(int x, byte r) ;Subroutine
with two input variables
sub blah3(int z)<-byte s,int t
;Subroutine with one input variable
(z)
;and two output variables (s, t)
sub blah4(@ax) ;One input variable, in
the .A (lo) and .X (hi)
;registers. @x @a @xy @yx ->
...end...